package com.gw.detail.controllor.detail;

import java.util.List;

import com.gw.detail.domain.Strasse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gw.detail.service.IStrasseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 道路数据Controller
 * 
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/strasse")
public class StrasseController extends BaseController
{
    @Autowired
    private IStrasseService strasseService;

    /**
     * 查询道路数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:strasse:list')")
    @GetMapping("/list")
    public TableDataInfo list(Strasse strasse)
    {
        startPage();
        List<Strasse> list = strasseService.selectStrasseList(strasse);
        return getDataTable(list);
    }

    /**
     * 导出道路数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:strasse:export')")
    @Log(title = "道路数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Strasse strasse)
    {
        List<Strasse> list = strasseService.selectStrasseList(strasse);
        ExcelUtil<Strasse> util = new ExcelUtil<Strasse>(Strasse.class);
        return util.exportExcel(list, "道路数据数据");
    }

    /**
     * 获取道路数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:strasse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(strasseService.selectStrasseById(id));
    }

    /**
     * 新增道路数据
     */
    @PreAuthorize("@ss.hasPermi('detail:strasse:add')")
    @Log(title = "道路数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Strasse strasse)
    {
        return toAjax(strasseService.insertStrasse(strasse));
    }

    /**
     * 修改道路数据
     */
    @PreAuthorize("@ss.hasPermi('detail:strasse:edit')")
    @Log(title = "道路数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Strasse strasse)
    {
        return toAjax(strasseService.updateStrasse(strasse));
    }

    /**
     * 删除道路数据
     */
    @PreAuthorize("@ss.hasPermi('detail:strasse:remove')")
    @Log(title = "道路数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(strasseService.deleteStrasseByIds(ids));
    }
}
